package com.ts.animal.service.impl;

import com.ts.animal.constant.AnimalConstant;
import com.ts.animal.dao.ExRfidLabelUseInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ts.animal.dao.RfidLabelUseInfoDao;
import com.ts.animal.domain.RfidLabelUseInfoDO;
import com.ts.animal.service.RfidLabelUseInfoService;
import com.ts.common.utils.Result;


@Service
public class RfidLabelUseInfoServiceImpl implements RfidLabelUseInfoService {
	@Autowired
	private RfidLabelUseInfoDao rfidLabelUseInfoDao;
	@Autowired
	private ExRfidLabelUseInfoDao exRfidLabelUseInfoDao;

	@Override
	public RfidLabelUseInfoDO get(String num){
		return rfidLabelUseInfoDao.get(num);
	}

	@Override
	public List<Map<String, Object>> list(Map<String, Object> map){
		map.put("settlementStatusYes", AnimalConstant.settlement_status_yes);
		map.put("settlementStatusNot", AnimalConstant.settlement_status_not);
		return exRfidLabelUseInfoDao.labelUseInfoList(map);
	}

	@Override
	public int count(Map<String, Object> map){
		return rfidLabelUseInfoDao.count(map);
	}

	@Override
	public int save(Result result,RfidLabelUseInfoDO rfidLabelUseInfo){
		 int ret = rfidLabelUseInfoDao.save(rfidLabelUseInfo);
		if(ret==0){
	    	result.set(Result.FAIL, "保存失败", null);
	    }
		return ret;


	}

	@Override
	public int update(Result result,RfidLabelUseInfoDO rfidLabelUseInfo){
	    int ret = rfidLabelUseInfoDao.update(rfidLabelUseInfo);
		if(ret==0){
	    	result.set(Result.FAIL, "更新失败", null);
	    }
		return ret;
	}

	@Override
	public int remove(Result result,String num){
	    int ret = rfidLabelUseInfoDao.remove(num);
	    if(ret==0){
	    	result.set(Result.FAIL, "删除失败", null);
	    }
		return ret;
	}

	@Override
	public int batchRemove(Result result,String[] nums){
		int ret = rfidLabelUseInfoDao.batchRemove(nums);
		 if(ret!=nums.length){
	    	result.set(Result.FAIL, "部分删除失败", null);
	    }
		return ret;
	}

}
